package class202205.demo15.demo12;

import java.util.Scanner;

public class demo20220512 {
    /**
     *
     * n!
     * @param n
     * @return
     */
    public static int suv(int n){
        int result = 1;
        for (int i = 1; i <= n; i++) {
            result *=i;
        }
        return result;
    }

    /**
     *
     * @param x = 5 ---> 1!+2!+3!+4!+5!
     * @return
     */
    public static int suvHaha(int x){
        int sun = 0;
        for (int i = 1; i <= x ; i++) {
            sun +=suv(i);
        }
        return sun;
    }


    public static void main(String[] args) {
        System.out.println(suvHaha(2));
    }

    public static void login(){
        int count = 3;
        Scanner sc = new Scanner(System.in);
        while (count != 0){
            System.out.println("请输入你的密码:");
            String password = sc.nextLine();
            if (password.equals("666")){
                System.out.println("登陆成功！");
                return;
            }else {
                System.out.println("输入错误，你还有 "+count+" 次机会！");
            }
        }
    }

    public static void main2(String[] args) {
        login();
    }

    public static void main1(String[] args) {
        int i =1;
        while (i <= 100){
            if (i % 15 != 0){
                i++;
                continue;
            }
            System.out.print(i+" ");
            i++;
        }
        System.out.println();
    }
}
